<uieip type="page" value="login" debug="true" timeout="5000"></uieip>
<uieip type="reg" value="console"></uieip>
<!DOCTYPE html>
<html>

<head>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/src/yqwin.min" cache="false"></uieip>
    <title>tree edit</title>
</head>

<body style="margin: 0;">
    <table>
        <tr>
            <td>
                <ul id="tt">
                </ul>
            </td>
            <td style="vertical-align: top;padding-top: 43px;">
                <form>
                    <table style="width: 100%;">
                        <tr>
                            <td style="width:350px;vertical-align: top;">
                                <div class="easyui-panel" title="editMode"
                                    style="width:100%;max-width:370px;padding: 5px;">
                                    <div id="div_editMode"></div>
                                </div>
                            </td>
                            <td style="width:260px;vertical-align: top;">
                                <div class="easyui-panel" title="editType"
                                    style="width:100%;max-width:370px;padding: 5px;">
                                    <div id="div_editType"></div>
                                </div>
                            </td>
                            <td style="width:100px;vertical-align: top;">
                                <div class="easyui-panel" title="editModeNo"
                                    style="width:100%;max-width:370px;padding: 5px;">
                                    <div id="div_editModeNo"></div>
                                </div>
                            </td>
                            <td style="vertical-align: top;">
                            </td>
                        </tr>
                    </table>
                </form>
                <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:reset()">reset</a>
            </td>
        </tr>
    </table>

    <script>
        var dbname = "yqbase";

        function form_load() {
            $(window).resize(function () {
                onresize();
            });
            onresize();

            $('#tt').yqTree("loadData");
        }

        function onresize() {
            $('#tt').yqTree("resize", {
                "width": 350,
                "height": $(window).height() - 50
            })
        }

        $(function () {
            $("#div_editMode").radiogroup({
                name: 'radio1',
                labelWidth: 340,
                data: [{
                    value: '3',
                    label: '编辑（不包含save按钮），弹出编辑模态窗体 1,2,3'
                }, {
                    value: '4',
                    label: '独立页面编辑，弹出编辑模态窗体'
                }],
                value: 4,
                dir: 'v'
            });

            $("#div_editType").radiogroup({
                name: 'radio2',
                labelWidth: 270,
                data: [{
                    value: '1',
                    label: '属性编辑模式 editMode=2,3使用',
                }, {
                    value: '2',
                    label: 'form编辑模式 editMode=2,3使用'
                }],
                value: 1,
                dir: 'v'
            });

            $("#div_editModeNo").radiogroup({
                name: 'radio3',
                labelWidth: 70,
                data: [{
                    value: '1',
                    label: '=1',
                }, {
                    value: '2',
                    label: '=2'
                }, {
                    value: '3',
                    label: '=3'
                }],
                value: 1,
                dir: 'v'
            });

            $.yqDbList({ ajaxUrl: "_db.html" },
                function (data) {
                    if (data.error == 0) {
                        dbname = data.rows[0].name;
                        init_tree();
                    } else {
                        alert(data.info);
                    }
                });
        })

        function init_tree() {
            $('#tt').yqTree({
                ajaxUrl: "/_db.html", //ajax地址
                dbname: dbname,   //数据库
                tbname: "ab_test_tree",       //表
                keyId: "sid",       //关键字段
                bindingKeyId: null,
                bindingValue: null,
                pKeyId: "pid",
                pKeyValue: null,

                loadDataType: 2,    //全局加载模式
                displayMember: "name",
                loadData: false,

                menuType: 3,  //1-顶部菜单，2-右键菜单，3-顶部+右键  其他，无菜单

                overflowY: true,
                //width: 180,
                //height: 300,
                state: true,
                state_field: "state",
                wflock: true,

                editMode: 4,
                editModeW: "90%",
                editModeH: "90%",
                editModeNo: -1,

                beforeBindingTitle: function (titles, callback) {
                    console.log("beforeBindingTitle", titles);
                    callback(titles);
                }, //标题绑定前
                afterBindingTitle: function () {
                    form_load();
                }, //标题绑定后

                beforeSetdata: function (data, callback) {
                    console.log("beforeSetdata", data);
                    callback(data)
                }, //绑定数据之前
                afterSetdata: function (data) {
                    console.log("afterSetdata", data);
                }, //绑定数据之后
                uppActionState: function (s_node, callback) {     //操作节点状态处理接口
                    console.log("uppActionState", s_node);
                    callback(true);
                },
            });
        }

        function reset() {
            $('#tt').yqTree({
                editMode: $("#div_editMode").radiogroup("getValue"),
                editType: $("#div_editType").radiogroup("getValue"),
                editModeNo: $("#div_editModeNo").radiogroup("getValue")
            });
        }
    </script>
</body>

</html>